package program;

import java.util.ArrayList;
/**
 * A class representing SExprList with an ArrayList from SExpressions.
 * 
 * @author Jef Keijers/Bachelor of Science: Informatics
 * @version 1.0
 */

public class SExprList extends SExpression { 

	/**
	 * This method returns the arraylist of SExpressions.	
	 */
	public ArrayList<SExpression> getList() {
		return list;
	}
	
	/**
	 * This method adds his parameter to the arraylist of SExpressions
	 * @param  expression
	 * 		   The expression to add.	
	 */
	public void add(SExpression expression) { 
		list.add(expression);
	}
	
	/**
	 * ArrayList containing SExpressions
	 */
	private ArrayList <SExpression> list=new ArrayList<SExpression>();

	/**
	 * This method returns a string representation of the SExpressions in the arraylist.
	 */
	@Override
	public String toString() {
		StringBuilder stringbuilder=new StringBuilder(); 
		stringbuilder.append("(");
		for (SExpression sexpr:list) {
			stringbuilder.append(sexpr.toString()+" ");
		}
		stringbuilder.append(")");
		
		return stringbuilder.toString();
	}
}
